package com.zp.proxy;/**
 * @description
 * @author zp
 * @created 2021/9/3 21:49
 */

import com.zp.entity.Blue;
import com.zp.entity.Color;
import com.zp.entity.Green;
import com.zp.entity.Red;

/**
 * @author zp
 * @description
 * @created 2021/9/3 21:49
 */
public class ColorProxy implements Color {
    private String colorName;
    private Color color;
    public ColorProxy(String colorName){
        this.colorName = colorName;
    }
    public void fill() {
        if(color == null){
            if("red" .equals( this.colorName)){
                this.color = new Red();
            }else if("blue" .equals( this.colorName)){
                this.color = new Blue();
            }else if("green".equals(this.colorName)){
                this.color = new Green();
            }
        }
        color.fill();
    }
}
